package cn.csc.module.order.dal.mysql.logistics;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.order.dal.dataobject.logistics.OrderLogisticsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.order.controller.admin.logistics.vo.*;

/**
 * 订单物流 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface OrderLogisticsMapper extends BaseMapperX<OrderLogisticsDO> {

    default PageResult<OrderLogisticsDO> selectPage(OrderLogisticsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderLogisticsDO>()
                .eqIfPresent(OrderLogisticsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderLogisticsDO::getExpressNo, reqVO.getExpressNo())
                .likeIfPresent(OrderLogisticsDO::getConsigneeRealname, reqVO.getConsigneeRealname())
                .eqIfPresent(OrderLogisticsDO::getConsigneePhone, reqVO.getConsigneePhone())
                .eqIfPresent(OrderLogisticsDO::getConsigneePhoneSpare, reqVO.getConsigneePhoneSpare())
                .eqIfPresent(OrderLogisticsDO::getConsigneeAddress, reqVO.getConsigneeAddress())
                .eqIfPresent(OrderLogisticsDO::getConsigneeZip, reqVO.getConsigneeZip())
                .eqIfPresent(OrderLogisticsDO::getLogisticsType, reqVO.getLogisticsType())
                .eqIfPresent(OrderLogisticsDO::getLogisticsFee, reqVO.getLogisticsFee())
                .eqIfPresent(OrderLogisticsDO::getOrderLogisticsStatus, reqVO.getOrderLogisticsStatus())
                .eqIfPresent(OrderLogisticsDO::getLogisticsSettlementStatus, reqVO.getLogisticsSettlementStatus())
                .eqIfPresent(OrderLogisticsDO::getLogisticsResultLast, reqVO.getLogisticsResultLast())
                .eqIfPresent(OrderLogisticsDO::getLogisticsResult, reqVO.getLogisticsResult())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsCreateTime, reqVO.getLogisticsCreateTime())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsUpdateTime, reqVO.getLogisticsUpdateTime())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsSettlementTime, reqVO.getLogisticsSettlementTime())
                .betweenIfPresent(OrderLogisticsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderLogisticsDO::getId));
    }

    default List<OrderLogisticsDO> selectList(OrderLogisticsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrderLogisticsDO>()
                .eqIfPresent(OrderLogisticsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderLogisticsDO::getExpressNo, reqVO.getExpressNo())
                .likeIfPresent(OrderLogisticsDO::getConsigneeRealname, reqVO.getConsigneeRealname())
                .eqIfPresent(OrderLogisticsDO::getConsigneePhone, reqVO.getConsigneePhone())
                .eqIfPresent(OrderLogisticsDO::getConsigneePhoneSpare, reqVO.getConsigneePhoneSpare())
                .eqIfPresent(OrderLogisticsDO::getConsigneeAddress, reqVO.getConsigneeAddress())
                .eqIfPresent(OrderLogisticsDO::getConsigneeZip, reqVO.getConsigneeZip())
                .eqIfPresent(OrderLogisticsDO::getLogisticsType, reqVO.getLogisticsType())
                .eqIfPresent(OrderLogisticsDO::getLogisticsFee, reqVO.getLogisticsFee())
                .eqIfPresent(OrderLogisticsDO::getOrderLogisticsStatus, reqVO.getOrderLogisticsStatus())
                .eqIfPresent(OrderLogisticsDO::getLogisticsSettlementStatus, reqVO.getLogisticsSettlementStatus())
                .eqIfPresent(OrderLogisticsDO::getLogisticsResultLast, reqVO.getLogisticsResultLast())
                .eqIfPresent(OrderLogisticsDO::getLogisticsResult, reqVO.getLogisticsResult())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsCreateTime, reqVO.getLogisticsCreateTime())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsUpdateTime, reqVO.getLogisticsUpdateTime())
                .betweenIfPresent(OrderLogisticsDO::getLogisticsSettlementTime, reqVO.getLogisticsSettlementTime())
                .betweenIfPresent(OrderLogisticsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderLogisticsDO::getId));
    }

}
